#include<bits/stdc++.h>
#define rep(U,V,W) for(int U=(V);U<=(W);U++)
typedef double db;
using namespace std;
const int N=3005;
int T,n,m,l,vm,da[N],v[N],a[N],mo[N],ans,bk[N],cnt[N],tor[N];
bool f[N][N];
int calv(int V,int A,int MO,int DA){
	db res=(db)V*(db)V+2*(db)A*((db)MO-(db)DA);
	if(res<=0) return 0;
	res=sqrt(res)*1000.0;
    return (int)res;
}
int main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	scanf("%d",&T);
    while(T--){
        ans=0;
        scanf("%d%d%d%d",&n,&m,&l,&vm);
        rep(i,1,n) scanf("%d%d%d",&da[i],&v[i],&a[i]);
        rep(i,1,m) scanf("%d",&mo[i]);
        rep(i,1,n){
            rep(j,1,m){
				if(da[i]>mo[j]) continue;
				int vc=calv(v[i],a[i],mo[j],da[i]);
                if(vc>vm*1000){
                    f[i][j]=1;
                    ans++;
					bk[i]=1;
                    if(a[i]>=0){
                        rep(k,j+1,m){
							f[i][k]=1;
						}
                        break;
                    }
                }
                if(a<=0&&vc<=vm*1000){
					break;
                }
            }
        }
        printf("%d ",ans);
        rep(i,1,n)
            rep(j,1,m)
                cnt[i]+=f[i][j];
        ans=0;
        bool flag=0;
        rep(j,1,m){
            rep(i,1,n)
				if(!cnt[i]||!f[i][j]) continue;
                else if(f[i][j]&&cnt[i]==1){
					printf("%d\n",ans);
					flag=1;
					break;
				}
                else if(f[i][j]&&cnt[i]>0){
					cnt[i]--;
				}
			if(flag) break;
            ans++;
        }
        if(!flag) printf("%d\n",m);
    }
	return 0;
}
